/**
 * Copyright (C) 2011  E-Robot
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 * @brief Robot.h
 *
 * @date 20 oct. 2010
 * @author Elias Capito
 * @version 0.1
 */

#ifndef ROBOT_H_
#define ROBOT_H_

#include "def.h"

#include "Map/Map.h"
#include <string>
#include "SonarGroup.h"
#include <libplayerc++/playerc++.h>
#include <qline.h>
using namespace PlayerCc;
using namespace std;

class Robot :public QObject
{
	Q_OBJECT
private:
	AlgoEnum m_state;
	SonarGroup m_groups;
	PlayerClient    *m_client;
	SimulationProxy *m_simProxy;
	Position2dProxy *m_p2dProxy;
	SonarProxy      *m_sonarProxy;
	vector<Sonar*> m_sonars;

	char* m_modelName;
	double m_newspeed;
	double m_newrotation;

	Map *m_map;

	double m_x, m_y;
	double m_angle;
public:
	Robot(string _model_name,string _host="localhost", int _port=6665);
	virtual ~Robot();
	void updateSonar();
	void updateRobotPosition();
	void process();
	void changeState(AlgoEnum _algo);

	void useMap(Map* _map);

private:
	void random();
	void followLeft();
	void followRight();

	void createSonar();

public Q_SLOTS:
	void changeAlgo();
Q_SIGNALS:
	void updateMap(QLineF line);
};

#endif /* ROBOT_H_ */
